import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.io.InputStream;

public class MybatisTest {

	public static void main(String[] args) throws IOException {
//      测试CarMapper.xml是否正确  能否和数据库连通
//		sqlsessionfactoryBulider

		SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
//		sqlsessionfactory
		InputStream inputStream = Resources.getResourceAsStream("CarMapper.xml");
		SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(inputStream);
//		sqlsession
		SqlSession sqlSession = sqlSessionFactory.openSession();

		int insertCar = sqlSession.insert("insertCar");
		System.out.println(insertCar);

		sqlSession.commit();
		sqlSession.close();



	}
}
